package com.celan.year2023.month05.day28;

/**
 * @author Celan
 * @description TODO
 */
public class Solution04 {
    public boolean increasingTriplet(int[] nums) {
        int n = nums.length;
        int min = Integer.MAX_VALUE, max = Integer.MAX_VALUE;
        for (int num : nums) {
            //更新最大值与最小值
            if (num < min) {
                //若num比min小 -> 相当于重新开始计算
                min = num;
            } else if (num > min && num < max) {
                //如果num比min大,比max小,说明以num作为max,更容易找到三元组
                max = num;
            } else if (num > max) {
                //如果num大于max,找到三元组
                return true;
            }
        }
        return false;
    }
}
